<!DOCTYPE html>
<html lang="zh_CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>事件</title>
    <script>
        // 将代码放在这个里面，可以确保页面加载完成再执JS行代码
        window.onload = function () {
            var btn = document.getElementById("btn");
            btn.onclick = function () {
                alert("你还点~~~");
            };
        };
    </script>
</head>
<body>
    <button id="btn">按钮</button>
</body>

</html>